package com.lk.controller;

import com.lk.entity.Record;
import com.lk.service.RecordService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * @author LuoKai
 */
@Controller
public class RecordController {

    @Resource
    private RecordService recordService;

    @RequestMapping("/")
    public String queryAll(Model model) {
        List<Record> records = recordService.findAll();
        model.addAttribute("records", records);
        return "index";
    }

    @RequestMapping("/delete/")
    public void delete(@RequestParam(value = "id") String id,
                       HttpServletResponse response) throws IOException {
        int deleteFlag = recordService.deleteById(id);
        response.getWriter().write("");
    }
}
